package com.finace.money.common.util;

import android.app.Activity;
import android.content.res.Resources;
import android.graphics.Color;
import android.support.v7.app.AlertDialog;
import android.support.v7.widget.ViewUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

import com.finace.money.R;

import javax.inject.Inject;

/**
 * Created by ZHP on 2017/7/3.
 */

public class AlertDialogUtil {


    @Inject
    public AlertDialogUtil() {
    }

    public AlertDialog createDialog(Activity activity){

        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
        /*View view = View
                .inflate(activity, R.layout.dialog_custom, null);
        builder.setView(view);

        builder.setCancelable(true);
        TextView title= (TextView) view
                .findViewById(R.id.title);//设置标题
        Button btn_cancel=(Button)view
                .findViewById(R.id.btn_cancel);//取消按钮
        Button btn_comfirm=(Button)view
                .findViewById(R.id.btn_comfirm);//确定按钮*/
        //取消或确定按钮监听事件处理
        AlertDialog dialog = builder.create();
        dialog.show();
        return dialog;
    }
    public static void setD(AlertDialog dialog){
        /*final Resources res = dialog.getContext().getResources();

        int topPanelId = res.getIdentifier("topPanel", "id", "android");//获取顶部
        LinearLayout topPanel = (LinearLayout) getDialog().findViewById(topPanelId);
        topPanel.setBackgroundResource(R.drawable.dialog_top_bg);//设置顶部背景
        LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, //设置顶部高度
                UIUtil.dip2px(getDialog().getContext(), 50));
        topPanel.setLayoutParams(params);

        int dividerId = res.getIdentifier("titleDivider", "id", "android");//设置分隔线
        View divider = getDialog().findViewById(dividerId);
        divider.setVisibility(View.GONE);

        int titleId = res.getIdentifier("alertTitle", "id", "android");//获取标题title
        TextView title = (TextView) getDialog().findViewById(titleId);//设置标题
        title.setTextColor(Color.WHITE);//标题文字颜色
        title.setTextSize(18);//文字大小
        title.setGravity(Gravity.CENTER);//文字位置

        int customPanelId = res.getIdentifier("customPanel", "id", "android");//设置内容
        FrameLayout customPanel = (FrameLayout) getDialog().findViewById(customPanelId);
        customPanel.setBackgroundColor(Color.TRANSPARENT);//背景透明
        customPanel.getChildAt(0).setBackgroundColor(Color.WHITE);
        customPanel.setPadding(UIUtil.dip2px(getContext(), 8), 0, UIUtil.dip2px(getContext(), 8), 0);//设置padding
        int buttonPanelId = res.getIdentifier("buttonPanel", "id", "android");//获取底部
        LinearLayout buttonPanel = (LinearLayout) getDialog().findViewById(buttonPanelId);
        buttonPanel.setBackgroundResource(R.drawable.dialog_bottom_bg);//设置底部背景
        buttonPanel.setPadding(UIUtil.dip2px(getContext(), 8), 1, UIUtil.dip2px(getContext(), 8), 0);

        Button button1 = (Button) getDialog().findViewById(android.R.id.button1);//设置底部Button
        button1.setTextColor(Color.WHITE);//文字颜色
        button1.setTextSize(18);//文字大小
        button1.setBackgroundResource(R.drawable.bg_right_round);//Button圆形背景框

        Button button2 = (Button) getDialog().findViewById(android.R.id.button2);
        button2.setTextColor(Color.WHITE);
        button2.setTextSize(18);
        button2.setBackgroundResource(R.drawable.bg_left_round);*/

    }

    public interface DoDiy{
        void doSelfDiy();
    };


    public interface onBackMethod{
        void onCancel();
        void onSure();
    }
}
